import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver } from '@angular/core';
import { ManagerPageComponent } from "../content/manager-page/manager-page.component";
import { ManagerService } from "./manager.service";

@Component({
  selector: 'app-manager',
  templateUrl: './manager.component.html',
  styleUrls: ['./manager.component.scss'],
  providers: [ManagerService]
})
export class ProductManagerComponent implements OnInit {
  // 投资经理页面
  @ViewChild("managerPage", { read: ViewContainerRef })
  managerPage: ViewContainerRef;
  managerPageComponent: ComponentRef<ManagerPageComponent>;

  constructor(
    public managerService: ManagerService,
    public resolver: ComponentFactoryResolver
  ) {

  }

  ngOnInit() {
    this.showManagerPage();
  }
  // 投资经理页面
  showManagerPage() {
    if (this.managerPageComponent && this.managerPageComponent.instance) {
      this.managerPageComponent.destroy();
    }
    const managerPageComponent = this.resolver.resolveComponentFactory(ManagerPageComponent);
    this.managerPageComponent = this.managerPage.createComponent(managerPageComponent);
  }
}
